<template>
    <div class="flex-main">
        <div class="flex-body">
            <ul class="m-evalue-tab">
                <li v-for="(item,index) in tabs" :key="index"
                :class="{'active':tabidx==index}" @click="setTab(index)">
                {{item}}({{listNum[index]}})
                </li>
            </ul>
            <no-data v-if="evaluatelist.length<1"></no-data>
            <div v-else>
                <evaluetion-listitem :evaluate="evaluatelist"></evaluetion-listitem>
            </div>
        </div>
        
    </div>
</template>
<script>
import {getGoodEvaluate} from '@/api/views';
export default {
    name:'',
    data () {
        return {
            tabs:['全部','好评','中评','差评'],
            tabidx:0,
            pageNo:1,
            list_rows:10,
            status:'',
            type: "", //商品类型 产品2、项目1、卡项3
            goodsid: "", //商品id
            evaluate_num:'',
            listNum:[0,0,0,0],      //评论数目
            evaluatelist:[],
        }
    },
    components: {
        evaluetionListitem:()=>import('@/model/evaluetion/evaluetion_listitem'),
    },
    methods: {
        setTab(index) {
            this.tabidx = index;
            if(index==0){
                this.status = '';
            }else{
                this.status = index;
            }
            this.goodEvaluate();
        },
        //   获取评价列表
        goodEvaluate() {
            this.$indicator.open('加载中...');
            let that = this;
            let param = {
                goods_id: that.goodsid,
                type: that.type, //商品类型：1项目 2是产品 3：卡
                status: that.status, //评价状态 ： 1:好评 ；2中评 ； 3差评
                page: that.pageNo,
                list_rows: that.list_rows,
            };
            getGoodEvaluate(param).then(response => {
                this.$indicator.close();
                that.evaluatelist = response.list.data;
                that.evaluate_num = response;
                that.listNum[0] = response.listNum;
                that.listNum[1] = response.listNumA;
                that.listNum[2] = response.listNumB;
                that.listNum[3] = response.listNumC;
            }).catch(error=>{});
        },
    },
    mounted() {
        let goodsid = this.$route.query.goodsid;
        let _type = this.$route.query.type;
        this.goodsid = goodsid;
        this.type = _type;
        this.goodEvaluate();
    }
}
</script>
<style lang="less" scoped src="@/less/evaluetion/evaluetion.less"></style>
